/*jslint maxerr: 50, indent: 4, browser: true */
/*global define */

define("string.split", ["mergeModules", "init", "array.push"], function (make) {
    "use strict";

    var buri = make.mergeModules(arguments),
        config = {
            "compatability": {}
        },
        split = (function () {
            var func = "".constructor.prototype.split;

            if (func) {
                return function (string, separator) {
                    return func.call(string, separator);
                };
            }

            return function stringSplit(string, separator) {
                var sLength = separator.length,
                    index = string.indexOf(separator),
                    array = [],
                    i = 0;

                while (index !== -1) {
                    buri.array.push(array, string.substring(i, index));
                    i = index + sLength;
                    index = string.indexOf(separator, i);
                }

                buri.array.push(array, string.substring(i));

                return array;
            };
        }());

    split.init = function (options) {
        buri.init(config, options);
        buri.array.push.init(config);
    };

    return {
        "string": {
            "split": split
        }
    };

});
